#include <iostream>
#include <string>

/*类*/
class Student
{
public:
    Student()
    {
        std::cout << "无参构造函数！" << std::endl;
    }

    Student(std::string name, int age)
    {
        std::cout << "带参构造函数！" << std::endl;
        m_name = name;
        m_age = age;
    }

    Student(Student &s)
    {
        std::cout << "拷贝构造函数！" << std::endl;
        m_name = s.m_name;
        m_age = s.m_age;
    }

    /*赋值运算符的重载      调用时机 ： s = s1*/
    void operator=(Student &s)
    {
        std::cout << "赋值运算符的重载！" << std::endl;
        m_name = s.m_name;
        m_age = s.m_age;
    }

    /*形式 ：无返回值，函数名和类名相同 前加 ~ ,无参数；*/
    /*不能重载*/
    /*自动调用*/
    ~Student()
    {
        std::cout << "析构函数！" << std::endl;
    }

    void SetName(std::string name);

    void SetAge(int age);

    void show();

private:
    /*成员变量（属性）*/
    std::string m_name;
    int m_age;
};

void Student::SetName(std::string name)
{
    m_name = name;
}

void Student::SetAge(int age)
{
    m_age = age;
}

void Student::show()
{
    std::cout << "学生姓名：" << m_name << " 学生年龄：" << m_age << std::endl;
}

int main()
{
    Student s("zhangsan", 21);

    // Student s1(s);
    // Student s1 = s;
    Student s1;
    s1 = s;

    s1.show();

    return 0;
}